package stool.iteratorpattern;

/**
 * @Author Felix YF Dong
 * @Date 2021/5/11
 */
public class Main {

    public static void main(String[] args) {

        ConcreteAggregate concreteAggregate = new ConcreteAggregate();
        for (int i = 0; i < 10; i++) {
            concreteAggregate.add(i);
        }

        Iterator i = new ConcreteIterator(concreteAggregate);

        Object object = i.first();
        while (!i.isDone()) {
            System.out.println(i.current());
            i.next();
        }

        Iterator desc = new ConcreteIteratorDesc(concreteAggregate);

        Object obj = desc.first();
        while (!desc.isDone()) {
            System.out.println(desc.current());
            desc.next();
        }

    }
}
